from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys
testCase = "DBshop029"

firefox = openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu3(firefox,'商品管理','商品标签','普通商品标签')

# 1.点击“添加普通商品标签”。
firefox.find_element_by_xpath('//a[contains(text(),"添加普通商品标签")]').click()
s=Select(firefox.find_element_by_id('tag_group_id'))
s.select_by_visible_text('华为老大')
# 2.填写标签分组“华为老大”，标签分组“华为手机，华为耳机”，标签排序255.
firefox.find_element_by_id('tag_name').send_keys('华为手机')
firefox.find_element_by_id('tag_name').send_keys(Keys.ENTER)
firefox.find_element_by_id('tag_name').send_keys('华为耳机')

# 3.点击“保存标签信息”，保存成功。
firefox.find_element_by_xpath('//button[contains(text(),"保存标签信息")]').click()

try:
    firefox.find_element_by_xpath('//td[text(),"华为手机"]') and firefox.find_element_by_xpath('//td[text(),"华为耳机"]')
    writeLog("%s 测试通过" % testCase)
except:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)

firefox.quit()